package com.chenfubing.ps.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenfubing.ps.entity.Space;
import com.chenfubing.ps.mapper.SpaceMapper;
import com.chenfubing.ps.service.ISpaceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chenfubing
 * @since 2020-05-05
 */
@Service
public class SpaceServiceImpl extends ServiceImpl<SpaceMapper, Space> implements ISpaceService {

    @Override
    public void addSpace(Space space) {
        baseMapper.insert(space);
    }

    @Override
    public void deleteSpace(int id) {
        baseMapper.deleteById(id);
    }

    @Override
    public Page<Space> getSpacePage(int pageNum,int pageSize) {
        return baseMapper.getSpacePage(new Page<>(pageNum,pageSize));
    }

    @Override
    public Integer getRemainingSpace() {
        return 400-baseMapper.selectCount(new QueryWrapper<>());
    }
}
